const app = getApp()
var utils = require('../../utils/util.js')
// var tongji = require('../../utils/tongji.js')
Page({
  data: {
    searchInput: '',
    imgUrls: [],
    displayList:[],
  },
  onLoad: function(options) {
    var that = this
    // if (options.scene) {
    //   tongji.updateOpenId(options.scene)
    // } else {
    //   tongji.updateOpenId(options.scene)
    // }
    wx.setStorageSync("share_id", options.share_id || 0);
  },
  onShow: function(options) {
    let that = this
    wx.request({
      url:
        app.urlData.getURL +
        '/index.php/Api/SApi/index/key/' +
        app.urlData.key +
        '/m/getNewSyGoodsList/wid/' +
        app.urlData.wid +
        '/sign/',
      method: 'GET',
      header: {
        'Content-Type': 'application/json'
      },
      data: {
        uid: wx.getStorageSync('ydn_id'),
        start: 0,
        len: 6
      },
      success: res => {
        that.setData({
          imgUrls: res.data.slidelist,
          displayList: res.data.picslidelist
        })
      }
    })
  },
  searchInput(e) {
    this.setData({
      searchInput: e.detail.value
    })
  },
  search() {
    if (this.data.searchInput == '') {
      wx.showToast({
        title: '请输入搜索内容',
        icon: 'none',
        duration: 1200
      })
      return false
    }
    wx.navigateTo({
      url:
        '/pages/searchResult/searchResult?searchInpu=' + this.data.searchInput
    })
  },



  // 轮播图详情
  goIndexDetails:function(e){
    wx.navigateTo({
      url: '/pages/indexDetails/indexDetails?id='+e.currentTarget.dataset.id,
    })
  },
  //点击指示点切换
  swiperClickEvent: function(e) {
    let that = this
    that.setData({
      swiperCurrent: e.currentTarget.dataset.id
    })
  },
  pageJump: function (e) {
    let data = e.currentTarget.dataset;
    wx.navigateTo({
      url: data.url
    })
  },
  onShareAppMessage: function(res) {
    return {
      title: "PAPARELA  我的御用化妆师",
    }
  },
})
